package org.leumasjaffe.initiativeTracker.entity;

import java.io.PrintStream;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
 * Class with data and methods managing Non-Player Characters
 * @author Sam Jaffe
 *
 */
@NonNullByDefault
public final class NPC extends Character{
	/**
	 * 
	 */
	private static final long serialVersionUID = 656870533173229678L;
	private boolean allied;
	private int count = 1;
	
	/**
	 * Generic NPC constructor for use in the NPC hashing system for easy lookup and in loading NPCs from a data file
	 * @param isAllied A boolean representing if this NPC is an ally to the Players
	 */
	public NPC(boolean isAllied) {
		super();
		setAllied(isAllied);
	}
	
	/**
	 * Standard constructor to create an NPC
	 * @param id The unique identification number for this NPC
	 * @param isAllied A boolean representing if this NPC is an ally to the Players
	 */
	public NPC (int id, boolean isAllied) {
		super(id);
		setAllied(isAllied);
	}
	
	/**
	 * Complete constructor, mirroring the arrangement of the previous constructor
	 * Only to be called from the CharacterImporter class
	 * @param count The count number of this NPC
	 * @param isAllied A boolean representing if this NPC is an ally to the Players
	 * @param isHidden A boolean representing whether the NPC's data will be obfuscated
	 */
	public NPC (boolean isAllied, int count) {
		setAllied(isAllied);
		setCount(count);
	}
	
	/**
	 * Exports the NPC data to the file in the PrintStream
	 * @param out The PrintStream to the file we are writing to
	 */
	@Override
	public void export(PrintStream out) {
		out.println("NON PLAYER:: " + this.count);
		out.println("FRIEND/FOE:: " + this.allied);
		super.export(out);
	}
	
	public void setAllied(boolean allied) {
		this.allied = allied;
	}

	public boolean isAllied() {
		return this.allied;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getCount() {
		return this.count;
	}
	
	@Override
	public String getName() {
		return super.getName() + " (" + this.getCount() + ")";
	}

	public String getShortName() {
		return super.getName();
	}

}